package com.jccit.wemedia.controller;

import com.jccit.wemedia.dto.WmChannelDto;
import com.jccit.wemedia.service.WmChannelService;
import com.jccit.wemedia.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/channel")
public class WmChannelController {

    @Autowired
    private WmChannelService wmChannelService;


    @PostMapping("/add")
    public ResponseResult add(@RequestBody WmChannelDto dto){

        return wmChannelService.add(dto);
    }


    @PutMapping("/update/{id}")
    public ResponseResult update(@PathVariable("id")Integer id, @RequestBody WmChannelDto dto){

        return wmChannelService.update(id,dto);
    }


    @DeleteMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id){

        return wmChannelService.delete(id);
    }


    @GetMapping("/{id}")
    public ResponseResult one(@PathVariable("id") Integer id){
        return wmChannelService.one(id);
    }


    @GetMapping("/list")
    public ResponseResult list(){
        return wmChannelService.list();
    }
}
